/* ThumbnailView */

#import <Cocoa/Cocoa.h>


@class FolderModel;
@class ThumbData;

@interface ThumbnailView : NSView
{
	NSMutableDictionary	*nameAttrs;
	int				textHeight;

	BOOL			showName;
	BOOL			showDate;
	BOOL			showThumbState;

	BOOL			extendedSelection;
	NSPoint			ptLastMouseDown;

	NSDateFormatter *dateFormatter;

	FolderModel		*folderModel;

	NSShadow		*shadow;
	int				maxTNWidth;
	int				maxTNHeight;

	// Used in 'calcAndSetSize' to limit resize thrashing (which probably
	// happens because I don't understand something properly).
	BOOL			calculatingSize;

	// By default, the thumbnail view is vertical - it's fixed to the current width and
	// grows downward. If 'isVertical' is false/NO, then the view is horizontal - it's
	// fixed to the current height and grows rightward.
	BOOL			isVertical;

	// By default, the thumbnail view is not a strip - it has more than one row or column
	// when enough items exist. If 'isAStrip' is true/YES, then we know that we have only
	// one row or column (depending on 'isVertical').
	BOOL			isAStrip;

	int				totalItemWidth;
	int				totalItemHeight;

	int				currentIndex;
	BOOL			*selectedItems;
	int				firstShiftSelection;

	BOOL			acceptsFirstResponder;

	id				delegate;
}

- (void) clearThumbnails;
- (void) calcAndSetSize;
- (FolderModel*) folderModel;
- (void) setFolderModel:(FolderModel*) fm  addThumbs:(BOOL) addThumbs;
- (void) thumbnailAvailable:(ThumbData*) td;

- (NSRect) rectFromIndex: (int) index;
- (int) indexFromThumbData: (ThumbData *) thumbData;
- (int) indexFromPoint: (NSPoint) point;

- (NSBezierPath*) getRoundedRect: (NSPoint) pt;

- (void) selectCurrent;
- (void) setCurrent:(int)index;
- (int) currentIndex;

- (NSArray *) selectedItems;
- (int) selectedCount;
- (BOOL) hasSelection;
- (void) clearSelection;
- (void) selectAll;
- (BOOL) isSelected: (int) index;
- (void) selectItem: (int) index  markSelected: (BOOL) select;
- (void) displayThumbData:(ThumbData*) td;

- (BOOL) vertical;
- (void) setVertical:(BOOL)vertical;

- (BOOL) isAStrip;
- (void) setIsAStrip:(BOOL) strip;

- (int) maxThumbWidth;
- (int) maxThumbHeight;

- (id) delegate;
- (void) setDelegate: (id) newDelegate;

- (BOOL) showDate;
- (BOOL) showName;

- (void) setAcceptsFirstResponder:(BOOL) accepts;
- (void) setForegroundColor:(NSColor*) newColor;
- (void) setShowDate:(BOOL) showDate;
- (void) setShowName:(BOOL) showName;

@end


// Delegate methods
@interface NSObject (ThumbnailViewDelegate)

- (void) thumbnailView
	: (ThumbnailView *) thView 
	selectionChanged: (int) index
	selected:(BOOL) selected
	item: (ThumbData *) td;

- (void) thumbnailView: (ThumbnailView*) tnView  doubleClicked:(NSString*) file;

@end


// Notifications

// The current index has changed - no data is sent with the notification (query the view
// for the current index)
extern NSString *TVCurrentIndexChangedNotification;
